#ifndef __CRYPT_H__
#define __CRYPT_H__
#include "../util.h"
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string>
DHS_API int encrypt(char *srcData, char *result, int Len);
// DHS_API int decrypt(char * key, char * data, char * result);

void generate_key(char *securityKey, int securityKeyLen);

#define SIGNATURE_LEN 256

BEGIN_DECAL_C
typedef struct _token_s
{
   time_t begin_time;
   time_t end_time; 
   time_t run_time;
   unsigned char signature[SIGNATURE_LEN]={0};
} token_s;
END_DECAL_C

class TokenManager
{
private:
token_s * token;
std::string token_path;
FILE *fp;
time_t last_time;
private:

int update_token();
void write_token();

public:
    TokenManager()=delete;
  explicit TokenManager(const char *token_dir);
    ~TokenManager();

    int parse_token();
    int token_expire();

};



void getTokenPath(const char * path,char * dest, int dest_len);
int create_token(const char * path,int days);
#endif